(*
This file is part of the Lustre reader

* Copyright (c) 2010, Nicola Camuffo.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*     * Neither the name of Nicola Camuffo, nor the
*       names of its contributors may be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)


open Lustypes


(* verifies if the expression is boolean. *)
val verify_boolean : _typed_expression -> unit

(* verifies if the expression is integer. *)
val verify_integer : _typed_expression -> unit

(* verifies if the expression is integer or real. *)
val verify_numeric : _typed_expression -> unit

(* verifies if the espression is a tuple. *)
val verify_tuple : _typed_expression -> unit

(* verifies if the espression is a struct. *)
val verify_struct : _typed_expression -> unit


(* verifies if both expressions are boolean. returns boolean type *)
val match_types_boolean : _typed_expression -> _typed_expression -> _type

(* verifies if both expressions are integer. returns integer type *)
val match_types_integer : _typed_expression -> _typed_expression -> _type

(* verifies if both expressions are numeric. returns integer or real type *)
val match_types_numeric : _typed_expression -> _typed_expression -> _type

(* verifies if both expressions are comparable using '<', '>', '<=', '>='. returns boolean type *)
val match_types_ltge : _typed_expression -> _typed_expression -> _type

(* verifies if both expressions are comparable using '=', '<>'. returns boolean type *)
val match_types_equals : _typed_expression -> _typed_expression -> _type

(* verifies if the three expressions are compatible for a if-then-else form: then first one must be boolean and the other of same type.
   returns type of the two branchs *)
val match_types_ite : _typed_expression -> _typed_expression -> _typed_expression -> _type

(* verifies if the expressions are compatible for a 'e1 -> e2' form. returns type of the expressions (same type) *)
val match_types_follby : _typed_expression -> _typed_expression -> _type

(* verifies if the expressions are compatible for a 'e when c' form. returns type of the first expression *)
val match_types_clocked : _typed_expression -> _typed_expression -> _type

(*
(* verifies if the three expressions are compatible for a 'with-then-else' form: then first one must be boolean and the other of same type.
   returns type of the two branchs *)
val match_types_wte : _typed_expression -> _typed_expression -> _typed_expression -> _type
*)

(* verifies if the expressions are compatible for a '#(e1,e2,..en)' or 'nor(e1,e2,..en)' form. returns boolean type *)
val match_types_bool_nary : _typed_expression list -> _type

(* given an expression list and a type list, verifies if expressions are compatible with types *)
val match_types_node_params : _typed_expression list -> _type list -> unit


(* verifies if the lhs and the expression are compatible. *)
val match_types_for_assignment : _typed_lhs -> _typed_expression -> unit
